Skip to content

fix: remove urlfave/cli built-in -h flag that is causing confusing behavior#2294

Merged
Stratus3D merged 1 commit into
masterfrom
tb/remove-global-h-flag
Jul 9, 2026
Merged

fix: remove urlfave/cli built-in -h flag that is causing confusing behavior#2294
Stratus3D merged 1 commit into
masterfrom
tb/remove-global-h-flag

Conversation

@Stratus3D

@Stratus3D Stratus3D commented Jul 8, 2026

Copy link
Copy Markdown
Member
  • Disable urfave/cli help command and global help flag
  • Print asdf help when no subcommand is specified
  • Print asdf help with error message when unknown subcommand is specified
  • Remove incorrect email

This fixes what was reported in #2228

Comment thread internal/cli/cli.go
log.SetFlags(0)

app := &cli.Command{
HideHelp: true,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't generate the global --help/-h flag or the urlfave/cli generated help command. Our own help subcommand is better. The -h help flag behavior was also confusing in contexts where the user did not intend to request the help output.

Comment thread internal/cli/cli.go
Action: func(_ context.Context, cmd *cli.Command) error {
// If no args, show help
if cmd.Args().Len() == 0 {
return helpCommand(logger, version, "", "")

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Show asdf's custom help output if no subcommand is specified.

Comment thread test/set_command.bats
[[ "$output" == *"No .tool-versions version file found in parent directory"* ]]
}

@test "set with -h flag should show error for undefined flag" {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without the above changes this test would fail.

Comment thread internal/cli/cli.go
Version: version,
Copyright: "(c) 2024 Trevor Brown",
Authors: []any{
mail.Address{Name: "Trevor Brown", Address: "someguy@example.com"},

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not my email address.

@Stratus3D Stratus3D marked this pull request as ready for review July 9, 2026 01:13
@Stratus3D Stratus3D requested a review from a team as a code owner July 9, 2026 01:13
@Stratus3D Stratus3D force-pushed the tb/remove-global-h-flag branch from 244655c to 1d57949 Compare July 9, 2026 12:48
…behavior

* Disable `urfave/cli` help command and global help flag
* Print asdf help when no subcommand is specified
* Print asdf help with error message when unknown subcommand is specified
* Remove incorrect email

This fixes what was reported in #2228
@Stratus3D Stratus3D force-pushed the tb/remove-global-h-flag branch from 1d57949 to 14eb087 Compare July 9, 2026 12:56
@Stratus3D Stratus3D changed the title chore: remove urlfave/cli built-in -h flag that is causing confusing behavior fix: remove urlfave/cli built-in -h flag that is causing confusing behavior Jul 9, 2026
@Stratus3D Stratus3D merged commit 017a770 into master Jul 9, 2026
11 of 13 checks passed
@Stratus3D Stratus3D deleted the tb/remove-global-h-flag branch July 9, 2026 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant